package com.mayikt.days03;

import java.util.concurrent.*;

/**
 * @ClassName Test040
 * @Author 蚂蚁课堂余胜军 QQ644064779 www.mayikt.com
 * @Version V1.0
 **/
public class Test040 {
    public static void main(String[] args) {
        // 底层中只会创建两个线程复用
        ExecutorService executorService = Executors.newFixedThreadPool(2);

        for (int i = 0; i < 10; i++) {
            int finalI = i;
            executorService.execute(() -> System.out.println(Thread.currentThread().getName() + "," + finalI));
        }
//        long endTime = System.currentTimeMillis();
//        System.out.println(endTime - startTime);
//        long startTime = System.currentTimeMillis();
//        for (int i = 0; i < 100; i++) {
//            int finalI = i;
//            new Thread(() -> System.out.println(Thread.currentThread().getName() + "," + finalI)).start();
//        }
////        long endTime = System.currentTimeMillis();
//        System.out.println(endTime - startTime);
        ExecutorService executorService1 = Executors.newFixedThreadPool(2);
//        ExecutorService executorService2 = Executors.newCachedThreadPool();
//        Executors.newSingleThreadExecutor();
//        Executors.newScheduledThreadPool(10);

    }
}
